package game

import (
	gamemap "FlyFight/Internal/GameMap"
	"FlyFight/Internal/cheese"
	"FlyFight/Internal/room"
	"sync"

	"github.com/gorilla/websocket"
)

type GameStatus uint8

const(
	Standing GameStatus = 0
	BeforeDice GameStatus = 1
	Dice GameStatus = 2
	AfterDice GameStatus = 3
	BeforeMove GameStatus = 4
	Move GameStatus = 5
	AfterMove GameStatus = 6
	BeforeAttack GameStatus = 7
	Attack GameStatus = 8
	AfterAttack GameStatus = 9
	BeforeDied GameStatus = 10
	Died GameStatus = 11
	AfterDied GameStatus = 12
)

type Order uint8
const(
	move Order = 0
	blood Order = 1
	message Order = 2
	addcheese Order = 3
	newturn Order = 4
	ready Order = 5
	teamchoose Order = 6
)

type Turn struct {
	turn []int
	turnpoint int
}

type Game struct {
	Map *gamemap.Bmap
	Room *room.Gameroom
	Ready chan struct{}
	Gamers map[uint32]*Gamer
	turn *Turn 
}

type GamePool struct {
	Mu sync.RWMutex
	Games map[int]*Game
}

var Gman *GamePool

type Gamer struct {
	Uid int
	Conn *websocket.Conn
	count uint8
	Cheese map[uint8]*cheese.FlyCh
	Buffer chan []byte
}

type Commend struct {
	Order uint8 `json:"Order"`
	Data []byte	`json:"Data"`
}